# qemu
# Builds from https://github.com/puppylinux-woof-CE/petbuilds
# File auto generated by ./mk_petbuild.sh. Edit as necessary.

. ../func
. ../build.conf

URL=http://wiki.qemu-project.org/download
PKG=qemu
VER=2.3.1
COMP=tar.bz2
DESC="qemu is an emulator and a virtualizer for linux"
DEPS=
CAT=BuildingBlock
DESKTOP=qemu.desktop
BUILD=
CWD=$(pwd)
[ -z "$MWD" ] && MWD=$(dirname $CWD)
[ -z "$BUILD" ] && BUILD=$DEF_BUILD
# comment these 2 below if you use a custom package() function
[ -f "$DESKTOP" ] || DESKTOP=not
[ -z "$DEPS" ] && DEPS=not

ARCH=$(uname -m)
case $ARCH in # set in build.conf
 *64) 	LIBDIR=$LIBCONF64 ; TYPE=x86_64-softmmu;;
 #arm*)	LIBDIR=$LIBCONFarm;;
 *) 	LIBDIR=$LIBCONF32 ; TYPE=i386-softmmu;;
esac

patch_me() {
	for i in *.patch; do 
		(cd ${PKG}-${VER}; patch -p1 < $CWD/$i)
	done
}

build() {
	cd ${PKG}-${VER}
	./configure --prefix=/usr --libdir=/usr/$LIBDIR \
		--sysconfdir=/etc --localstatedir=/var --source-path=$CWD/${PKG}-${VER} \
		--target-list="arm-softmmu arm-linux-user $TYPE" \
		--audio-drv-list="alsa sdl"  \
		--enable-guest-base --enable-guest-agent \
		--with-sdlabi=1.2
	make $MKFLG || exit
	make DESTDIR=$CWD/${PKG}-install install
	install -m 0644 $CWD/uefi-bios.bin $CWD/${PKG}-install/usr/share/qemu/
	cd -
}

# main
retrieve ${PKG}-${VER}.${COMP}
extract ${PKG}-${VER}.${COMP}
patch_me
build $PKG $VER $LIBDIR
package_std $PKG $VER $ARCH $DESKTOP "$DESC" $DEPS $CAT
